<?php
//get_material_content 获取素材的内容
header('Content-Type:text/html;charset=utf8');
require_once __DIR__ . "/../db_orm.php";
require_once __DIR__ . "/../function.php";

use Illuminate\Database\Capsule\Manager as DB;

$db_table1 = 'product';
$db_table2 = 'news';

$res = DB::table($db_table2)->where('open', 0)->select('id', 'guid')->get();

//5118配置
$host = "http://apis.5118.com";
$path = "/api/sucai";
$method = "POST";
$apikey = "BF74BDDCF7584279ABE28C0707ECC4D4";
$headers = array();
array_push($headers, "Authorization:" . $apikey);
//根据API的要求，定义相对应的Content-Type
array_push($headers, "Content-Type" . ":" . "application/x-www-form-urlencoded; charset=UTF-8");
$url = $host . $path;

if (!empty($res)) {
    foreach ($res as $value) {
        $bodys = "guid=" . $value['guid'];
        $bodyInfo = curl_post($url, $headers, $bodys);
        $bodyInfo = json_decode($bodyInfo, true);
//        var_dump($bodyInfo);exit();
    }
}